import java.util.*;

public class Solution {
    List<List<Integer>> ans = new ArrayList<>();
    void DFS(int[] nums, int cur, List<Integer> path){
        if(cur >= nums.length){
            ans.add(new ArrayList<Integer>(path));
            return;
        }

        for(int i = 0; i < path.size(); i++){
            if(path.get(i) == 11){
                path.set(i, nums[cur]);
                DFS(nums, cur + 1, path);
                path.set(i, 11);
            }
        }
    }

    public List<List<Integer>> permute(int[] nums) {
        List<Integer> path = new ArrayList<>();
        for(int i = 0; i < nums.length; i++){
            path.add(11);
        }
        DFS(nums, 0, path);
        return ans;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.permute(new int[]{1,2,3});
    }
}